#include "UnaryOp.h"
#include "IVisitor.h"

UnaryOp::UnaryOp(int op, const exprTypePtr& operand, int nodeId):
    exprType(nodeId),
    _op(op),
    _operand(operand)
{
}
    
UnaryOp::~UnaryOp()
{
    
}
    
Ast::AstTypes UnaryOp::type() const
{
    return Ast::UnaryOp;
}
    

int UnaryOp::op()
{
    return _op;
}

void UnaryOp::setOp(int op)
{
    _op = op;
}

exprTypePtr UnaryOp::operand()
{
    return _operand;
}

void UnaryOp::setOperand(const exprTypePtr& operand)
{
    _operand = operand;
}

    
QString UnaryOp::toString() const
{
    return QString("UnaryOp[op=%1, operand=%2]").
                arg(_op).
                arg(_operand ? _operand->toString():"");
}
    
void UnaryOp::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitUnaryOp(node.dynamicCast<UnaryOp>());
}
    
void UnaryOp::traverse(IVisitor* visitor)
{
    if (_operand != NULL)
        _operand->accept(visitor, _operand);
}